FileWrite command

Syntax
FileWrite refNum, data

Description
Writes data to a file opened with FileOpen, beginning at the current mark (position). After writing data, the file’s mark is set to the byte following the last byte written.

Note:  If not used carefully, FileWrite can potentially overwrite data in the specified file. Don't use FileWrite unless you are confident with reading and writing directly to files. For more information on file manipulation using the FileIO Extension, see “Reading and writing data files” on page 136.

Examples
Variable theFile, theData, refNum
theFile = (FindFolder "desk") & "FileIO Demo"
theData = "First line" & Return & "Second line"

refNum = FileOpen theFile
FileWrite refNum, theData      // write the data to the file
FileClose refNum

refNum = FileOpen theFile
FileSetPos refNum, 11      // set the mark (position) for the next read/write
FileWrite refNum, "••••••"      // Write text starting at the 12th byte (following the mark at 11)
FileSetPos refNum, 0      // reset the mark to the beginning of the file
theData = FileRead refNum, "all"
FileClose refNum
Message theData

See Also
Using the FileIO extension (page 136)

Author Info
FileWrite, part of FileIO Extension
Copyright © 1998 Life OnLine Software (lr). All rights reserved.